<template>
  <div>
    <div class="head"><img src="../../../static/images/banner1.jpg"></div>
    <!-- :companyName.sync="companyName" -->
    <i-panel>
      <view class="pageTitle">企业信息</view>
      <i-input
        title="企业名称"
        maxlength="50"
        :value="COMPANY_NAME"
        @change="handleChange($event,'COMPANY_NAME')"
      />
      <i-input
        :value="COMPANY_ADDR"
        @click="showCityPicker"
        title="企业所在地"
        disabled
        maxlength="100"
      />
      <mpvue-city-picker
        ref="mpvueCityPicker"
        :pickerValueDefault="pickerValueDefault"
        @onChange="onChange"
        @onCancel="onCancel"
        @onConfirm="onConfirm"
      ></mpvue-city-picker>
      <i-input
        :value="COMPANY_CERT_TYPE"
        title="公司证件类型"
        disabled
        maxlength="20"
      />
      <i-input
        :value="COMPANY_CERT_NUM"
        title="公司证件号码"
        maxlength="50"
        @change="handleChange($event,'COMPANY_CERT_NUM')"
      />
    </i-panel>

    <i-panel>
      <view class="pageTitle">经办人信息</view>
      <i-input
        :value="ATTN_NAME"
        title="经办人姓名"
        maxlength="10"
        @change="handleChange($event,'ATTN_NAME')"
      />
      <i-input
        :value="ATTN_PHONE"
        type="number"
        maxlength="11"
        title="经办人手机号"
        @change="handleChange($event,'ATTN_PHONE')"
      />
      <i-input
        :value="ATTN_CERT_TYPE"
        title="经办人证件类型"
        disabled
        maxlength="10"
      />
      <i-input
        :value="ATTN_CERT_NUM"
        title="经办人证件类型号码"
        maxlength="18"
        @change="handleChange($event,'ATTN_CERT_NUM')"
      />
       <i-input
        :value="ATTN_CERT_ADDR"
        title="经办人证件地址"
        maxlength="18"
        @change="handleChange($event,'ATTN_CERT_ADDR')"
      />
    </i-panel>

    <i-button
      @click="toNextUpload"
      type="success"
    >下一步</i-button>

  </div>
</template>

<script>
import "mpvue-weui/src/style/weui.css";
import mpvueCityPicker from "mpvue-citypicker";

export default {
  /* template:'<i-action-sheet @click="clickt"/>', */
  props: ["value"],
  data() {
    return {
      pickerValueDefault: [0, 0, 0],
        COMPANY_NAME: "",//企业名称
        COMPANY_CERT_TYPE:"营业执照",//企业证件类型
        COMPANY_CERT_NUM:'',//公司证件号码
        COMPANY_ADDR:'',//公司地址
        ATTN_NAME:'',//经办人姓名
        ATTN_CERT_TYPE:'',//经办人证件类型
        ATTN_CERT_NUM :'',// 经办人证件号码
        ATTN_CERT_ADDR:"",//经办人证件地址
        ATTN_CERT_TYPE:'身份证',//企业证件类型
        ATTN_PHONE:'',//经办人电话
        code:"",//修改or新增符
      // companyName:"",
      // companyArea:"",
      // companyLicType:"营业执照",
      // companyLicNum: "",
      // userName: "",
      // userPhone: "",
      // userLicType: "身份证",
      // userLicNum: "",
      // userLicAdd:"",
      obj: {
         COMPANY_NAME: "",//企业名称
        PHONE: "",//绑定手机
        COMPANY_ADDR:'',//公司地址
        ATTN_NAME:'',//经办人姓名
        ATTN_CERT_TYPE:'',//经办人证件类型
        ATTN_CERT_NUM :'',// 经办人证件号码
        ATTN_CERT_ADDR:"",//经办人证件地址
        ATTN_CERT_TYPE:'',//企业证件类型
        ATTN_PHONE:'',//经办人电话
        code:"",
      },
      CompanyInfo:[],
      objStorge:[],
       
    };
  },

  components: {
    mpvueCityPicker
  },

  methods: {
    showCityPicker() {
      let that = this;
      that.$refs.mpvueCityPicker.show();
    },
    onConfirm(e) {
      let that = this;
      console.log(e);
      that.companyArea = e.label;
    },
    handleChange(event, str) {
      this[str]= event.target.detail.value;
      console.log(this[str]);
    },
    toNextUpload() {
      let that = this;
      that.obj.COMPANY_NAME = that.COMPANY_NAME;
      that.obj.ATTN_CERT_ADDR = that.ATTN_CERT_ADDR;
      that.obj.COMPANY_CERT_NUM = that.COMPANY_CERT_NUM;
      that.obj.ATTN_NAME = that.ATTN_NAME;
      that.obj.ATTN_PHONE = that.ATTN_PHONE;
      that.obj.COMPANY_ADDR = that.COMPANY_ADDR;
      that.obj.ATTN_CERT_ADDR = that.ATTN_CERT_ADDR;
      that.obj.ATTN_CERT_NUM = that.ATTN_CERT_NUM
      that.obj.code = this.code;
      wx.setStorageSync("objStorge", that.obj);
      if (
        that.obj.companyName == "" ||
        that.obj.companyArea == "" ||
        that.obj.companyLicType == "" ||
        that.obj.companyLicNum == "" ||
        that.obj.userName == "" ||
        that.obj.userPhone == "" ||
        that.obj.userLicType == "" ||
        that.obj.userLicNum == ""
      ) {
        console.log(that.obj);
        wx.showToast({
          title: "内容有空值，请重新填写", //标题
          icon: "none"
        });
        return;
      }

      mpvue.navigateTo({
        url: "/pages/uploadtwo/main?info=" + JSON.stringify(that.obj)
      });
    }
  },
  onLoad: function(options) {
    let that = this;
     wx.showLoading({
        title: '数据加载中',
        })
    var obj = options.info;
    this.code =obj;
    console.log(this.code);
    that.CompanyInfo = wx.getStorageSync("CompanyInfo");
    console.log(that.CompanyInfo.COMPANY_NAME);
    that.COMPANY_NAME = that.CompanyInfo.COMPANY_NAME||"";
    that.ATTN_CERT_ADDR = that.CompanyInfo.ATTN_CERT_ADDR||"";
    that.COMPANY_CERT_NUM = that.CompanyInfo.COMPANY_CERT_NUM||"";
    that.ATTN_NAME = that.CompanyInfo.ATTN_NAME||"";
    that.ATTN_CERT_NUM = that.CompanyInfo.ATTN_CERT_NUM||"";
    that.ATTN_CERT_ADDR = that.CompanyInfo.ATTN_CERT_ADDR||"";
    that.ATTN_PHONE =  that.CompanyInfo.ATTN_PHONE||"";
    that.COMPANY_ADDR = that.CompanyInfo.COMPANY_ADDR || "";
     setTimeout(function(){
        wx.hideLoading()
      },500)
    // }
  },
  mounted() {
  },

  created() {}
};
</script>

<style lang="scss" scoped>
.head {
  img {
    width: 100%;
    height: 150px;
  }
}
.pageTitle {
  font-size: 25px;
  font-family: "微软雅黑";
  font-weight: bold;
  margin: 5px 10px;
}
</style>